﻿using System;
using System.Runtime.InteropServices;
using System.Windows;

namespace MimicAPI.DWM
{
    [StructLayout(LayoutKind.Sequential)]
    struct DWM_ThumbnailProperties
    {
        public DWM_ThumbnailFlags Flags;
        public DWM_Rect Destination;
        public DWM_Rect Source;
        public Byte Opacity;
        public bool Visible;
        public bool SourceClientAreaOnly;
    }

    struct DWM_Size
    {
        public int Width, Height;
        public static implicit operator Size(DWM_Size elt) { return new Size(elt.Width, elt.Height); }
    }

    [StructLayout(LayoutKind.Sequential)]
    struct DWM_Rect
    {
        public int Left, Top, Right, Bottom;
        public static implicit operator Rect(DWM_Rect elt)
        {
            return new Rect(elt.Left, elt.Top, elt.Right, elt.Bottom);
        }
        public static explicit operator DWM_Rect(Rect elt)
        {
            return new DWM_Rect()
            {
                Left = (int)Math.Ceiling(elt.Left),
                Top = (int)Math.Ceiling(elt.Top),
                Right = (int)Math.Ceiling(elt.Right),
                Bottom = (int)Math.Ceiling(elt.Bottom)
            };
        }
    }

    [StructLayout(LayoutKind.Sequential)]
    struct DWM_Blurbehind
    {
        /// <summary>Flags that indicates the given parameters</summary>
        public DWM_BlurbehindFlags dwFlags;
        /// <summary>True if the transparency is enabled</summary>
        public bool fEnable;
        /// <summary>Region</summary>
        public IntPtr hRgnBlur;
        public bool fTransitionOnMaximized;
    }

    [Flags]
    enum DWM_ThumbnailFlags : uint
    {
        RectDestination = 1,
        RectSource = 2,
        Opacity = 4,
        Visible = 8,
        SourceClientAreaOnly = 0x10
    }

    [Flags]
    enum DWM_BlurbehindFlags : uint
    {
        /// <summary>Flag Transparency Enabled</summary>
        Enable = 1,
        /// <summary>Flag Region</summary>
        BlurRegion = 2,
        /// <summary>Flag Transition on maximized</summary>
        TransitionOnMaximized = 4
    }
}
